<template>
	<view>
		<u-navbar :border-bottom="false" title="职位" :title-size="36" :title-bold="true" :title-color="textColor" :background="{backgroundColor: bgColor}">
		</u-navbar>
		<view class="u-m-b-20">
			<u-cell-group :border="false">
				<u-cell-item v-for="(item, index) in positionList" :title="item.name" value="已开通" @click="toPage('quanxian', item)" :key="index"></u-cell-item>
			</u-cell-group>
		</view>
		<set-submit-bt text="添加职位" bgColor="#F8F8F8" @click="toPage('quanxian', { id: '', name: '' })" />
		<akLoading isFullScreen :active="loading"></akLoading>
	</view>
</template>

<script>
	import { useShopStore } from '@/store/shop.js';
	import { mapState } from 'pinia';
	import SetSubmitBt from '@/components/set-submit-bt/index.vue'
	export default {
		components: { SetSubmitBt },
		data() {
			return {
				positionList: [],
				labelStyle: {
					fontSize: '30rpx',
				},
				buttonStyle: {
					height: '90rpx',
					color: '#FFFFFF',
					background: this.linearGradient
				},
				shopId:'',
				loading:false,
			}
		},
		
		onLoad(options) {
			this.shopId = options.shopId;
			// 获取职位列表
			this.getPositionList()
		},
		onShow() {
			// 获取职位列表
			this.getPositionList()
		},
		computed:{
			...mapState(useShopStore, {storeShop: 'shop',setPositionInfo:'setPositionInfo'})
		},
		methods: {
			async getPositionList() {
				this.loading = true;
				const res = await this.$setHttp.get('api/Shop/PositionList', { params: { id: this.shopId},header:{shopId:this.shopId} });
				this.loading = false;
				this.positionList = res.data;
			},
			handleSubmit() {
				this.$mRouter.push({
					route: '/pages/purchase/shezhi/quanxian?name=' + name+'&shopId='+this.shopId
				})
			},
			toPage(page, item) {
				// const info = {
				// 	id: item.id,
				// 	name: item.name
				// }
				console.log(item)
				this.setPositionInfo(item)
				this.$mRouter.push({
					route: '/pages/purchase/shezhi/quanxian?shopId='+this.shopId
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
</style>
